package org.liulinlin.sejw.db;

import java.sql.*;

public class BoxAndGoods {
	private int id;
	private Box box;
	private Goods goods;
	private int goodsNum;
	
	public BoxAndGoods() {
		
	}
	public BoxAndGoods(int id) {
		DBConnectionManager connMgr = DBConnectionManager.getInstance();
		Connection con = connMgr.getConnection("shipping_export");
		if (con == null) {
			System.out.println("BoxAndGoods不能获得数据库连接");
			return;
		}
		
		try {
			Statement stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery("select * from BoxAndGoods where BAG_ID = '" + id + "'");
			
			rs.next();
			this.id = id;
			box = new Box(rs.getString("Box_ID"));
			goods = new Goods(rs.getString("Goods_ID"));
			goodsNum = rs.getInt("BAG_GoodsNum");
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		connMgr.freeConnection("shipping_export", con);
		connMgr.release();
	}
	
	public void setId(int id) {
		this.id = id;
	}
	public void setBox(Box box) {
		this.box = box;
	}
	public void setGoods(Goods goods) {
		this.goods = goods;
	}
	public void setGoodsNum(int goodsNum) {
		this.goodsNum = goodsNum;
	}
	
	public int getId() {
		return id;
	}
	public Box getBox() {
		return box;
	}
	public Goods getGoods() {
		return goods;
	}
	public int getGoodsNum() {
		return goodsNum;
	}
}
